﻿Namespace Utility

    Public Class clsAlertMsg

        Public Shared Sub alert(ByVal Page As Object, ByVal msg As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & msg & "');</script>")
        End Sub


        Public Shared Sub alert_location(ByVal Page As Object, ByVal msg As String, ByVal pLocation As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & msg & "');window.location='" & pLocation & "';</script>")
        End Sub


        Public Shared Sub alert_close(ByVal Page As Object, ByVal msg As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & msg & "');window.close();</script>")
        End Sub

        Public Shared Sub close_page(ByVal Page As Object)
            Page.RegisterStartupScript("Onload", "<script>window.close();</script>")
        End Sub

       
        Public Shared Sub windowRefresh(ByVal Page As Object, ByVal strMsg As String, ByVal PageRefresh As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & strMsg & "');self.opener.location='" & PageRefresh & "';window.close();</script>")
            'ScriptManager.RegisterClientScriptBlock(Page, Page.GetType, "Onload", "<script>alert('" & strMsg & "');self.opener.location='" & PageRefresh & "';window.close();</script>", False)

        End Sub

        Public Shared Sub windowLocation(ByVal p As Page, ByVal PageLocation As String)
            p.ClientScript.RegisterClientScriptBlock(GetType(String), "WindowLocation", "window.location='" & PageLocation & "';", True)
            'ScriptManager.RegisterClientScriptBlock(p, GetType(String), "WindowLocation", "window.location='" & PageLocation & "';", True)
        End Sub

        Public Shared Function infoMessage(ByVal img As Image, ByVal code As String, ByVal strMsg As String) As String
            Try

                ' Dim Img As Image = page.FindControl("ImgShowError")
                Dim SubCode As String = code.Substring(0, 1)
                If SubCode = "I" Then
                    img.ImageUrl = "~/img/Error01.gif"
                ElseIf SubCode = "W" Then
                    img.ImageUrl = "~/img/Error02.gif"
                ElseIf SubCode = "E" Then
                    img.ImageUrl = "~/img/Error03.gif"
                End If
            Catch ex As Exception

            End Try


            'Dim rs As String = ""
            'rs = ConfigurationSettings.AppSettings(code)
            ' infoMessage = String.Format(rs, strMsg)
            infoMessage = strMsg
            Return infoMessage
        End Function
        Public Shared Function infoMessage(ByVal img As Image, ByVal code As String) As String
            Try
                ' Dim Img As Image = Page.FindControl("ImgShowError")
                Dim SubCode As String = code.Substring(0, 1)
                If SubCode = "I" Then
                    img.ImageUrl = "~/img/Error01.gif"
                ElseIf SubCode = "W" Then
                    img.ImageUrl = "~/img/Error02.gif"
                ElseIf SubCode = "E" Then
                    img.ImageUrl = "~/img/Error03.gif"
                End If
            Catch ex As Exception

            End Try

            Dim rs As String = ""
            rs = ConfigurationSettings.AppSettings(code)
            Return rs
        End Function
    End Class
End Namespace